#ifndef VECTOR_H_
#define VECTOR_H_

#include <stddef.h>

typedef struct _vector_t {
    size_t size;
    size_t capi;
    void **vals;
} vector_t;

#define vector_initializer { 0, 0, NULL}

vector_t *vector_new();

void vector_free(vector_t *obj);

void vector_clear(vector_t *obj);

size_t vector_size(const vector_t *obj);

void *vector_get(const vector_t *obj, size_t idx);

void vector_set(vector_t *obj, size_t idx, void *val);

int vector_add(vector_t *obj, void *val);

typedef void (*vector_foreach_callback)(void *ptr);

void vector_foreach(const vector_t *obj, vector_foreach_callback cb_function);

void vector_foreach_r(const vector_t *obj, vector_foreach_callback cb_function);

void *vector_item_new(size_t size);

void vector_item_free(void *ptr);

//释放由vector_item_new分配的每个item
void vector_foreach_free(const vector_t *obj);

#endif /* VECTOR_H_ */
